import { menuList } from '../../../request/api'
// menu组件
const state = {
    menulist: [],//菜单列表
}
const mutations = {
    // 修改菜单列表
    SET_MENU_LIST(state, payload) {
        state.menulist = payload;
    }
}

const actions = {
    // 请求菜单列表
    getMenuList({ commit }) {
        // istree 是否返回树状结构
        menuList({istree:1}).then(res => {
            commit('SET_MENU_LIST', res.list);
        })
    }
}

const getters = {
    getMenuList(state) {
        return state.menulist
    }
}

export default {
    state, mutations, actions, getters,
    namespaced:true,//开启命名空间
}